package com.aplink.generic.widgets;

import android.location.Location;
import android.view.View;
import android.view.View.OnClickListener;

import com.aplink.generic.GenericFragment;
import com.aplink.generic.dictionary.GenericDictionary;
import com.aplink.generic.interfaces.OnGetObjProInfo;
import com.aplink.generic.pojo.GenericAttribute;
import com.aplink.generic.pojo.controlspec.ControlSpec;
import com.aplink.generic.pojo.controlspec.GoogleMapsSpec;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;

public class ApLinkGoogleMaps extends ApLinkBaseView implements
		LocationListener {
	/**
     * 
     */
	private static final long serialVersionUID = -4974490991199634699L;
	private final GoogleMap mGoogleMap;
	private final GoogleMapsSpec mGoogleMapsSpec;
	
	public ApLinkGoogleMaps(final GenericFragment genericFragment,
			final ControlSpec controlSpec, final View view) {
		super(genericFragment, controlSpec, view);
		mGoogleMap = ((SupportMapFragment) getChildFragmentManager()
				.findFragmentById(controlSpec.getIDValue())).getMap();
		mGoogleMapsSpec = (GoogleMapsSpec) controlSpec;
	}
	
	@Override
	public void clear() {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public GenericAttribute getAttribute() {
		// TODO Auto-generated method stub
		return null;
	}
	
	@Override
	public GenericDictionary<String, GenericAttribute> getListAttributes() {
		return null;
	}
	
	@Override
	public View getView() {
		return null;
	}
	
	@Override
	protected void initViewProperties() {
		mGoogleMap.setMapType(mGoogleMapsSpec.getGoogleMapsType().getValue());
		mGoogleMap.getUiSettings().setScrollGesturesEnabled(
				mGoogleMapsSpec.isUiScrollGestures());
		mGoogleMap.getUiSettings().setCompassEnabled(
				mGoogleMapsSpec.isUiCompass());
		mGoogleMap.getUiSettings().setRotateGesturesEnabled(
				mGoogleMapsSpec.isUiRotateGestures());
		mGoogleMap.getUiSettings().setZoomControlsEnabled(
				mGoogleMapsSpec.isUiZoomControls());
		mGoogleMap.getUiSettings().setZoomGesturesEnabled(
				mGoogleMapsSpec.isUiZoomGestures());
		if (mGoogleMapsSpec.isLoadGPSLocation()) {
			
		} else {
			mGoogleMap.animateCamera(CameraUpdateFactory
					.newCameraPosition(CameraPosition
							.builder()
							.tilt((float) mGoogleMapsSpec.getCameraTilt())
							.zoom((float) mGoogleMapsSpec.getCameraZoom())
							.target(new LatLng(mGoogleMapsSpec
									.getCameraTargetLat(), mGoogleMapsSpec
									.getCameraTargetLng())).build()));
		}
	}
	
	@Override
	protected void loadBindingObject() {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	protected void loadDefaultObject() {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public void onLocationChanged(final Location arg0) {
		
	}
	
	@Override
	protected void setEventListener() {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public void setObjPropInfoTemp(final OnGetObjProInfo getObjProInfo) {
		
	}
	
	@Override
	public void setOnClickListener(final OnClickListener onClickListener) {
		
	}
	
}
